package com.grantha.controllers;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;
import java.text.DateFormat;
import java.util.Calendar;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.grantha.util.DB;
import com.grantha.util.Util;

/**
 * Servlet implementation class ReservationLetterController
 */
@WebServlet("/ReservationLetterController")
public class ReservationLetterController extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("application/json");
		PrintWriter out = response.getWriter();
		
	    Calendar c = Calendar.getInstance();
	    DateFormat df   = DateFormat.getDateInstance(DateFormat.FULL);   
	   
	    c.roll(Calendar.DAY_OF_YEAR, +14);
	    
	    String bookNo = request.getParameter("bookNo");    
	        
	        
//	        try {
//	            ResultSet rs = DB.search("select wishersno from reservation_list where bookno = '"+jFormattedTextField1.getText().trim()+"'");
//	            if(rs.next()){
//	            	
//	                viewReport.CreateReport.showReport("ReservationLetter", "parameter1#"+rs.getString("wishersno"), "parameter2#"+grantha.Df.format(c.getTime()));
//	                DB.update("delete from reservationlist where bookno = ?", );                                 
//	                
//	            }else{ 
//	                out.write(Util.sendJSONMessage(false, "This books ins't reserved"));
//	            }
//	        } catch (Exception e) { 
//	            grantha.ExceptionHandler.writeException(e);
//	        }
	    
	    
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
